/**
 * @(#)TaskInstanceCommentListTag.java Jan 20, 2010
 *   
 * Copyright  (c) 2009-2010 Wilmar IT Service,  Inc.   
 * All  rights  reserved.   
 * TODO
 */

package com.wilmar.process.web.taglibs;

import javax.servlet.jsp.JspWriter;

import com.wilmar.process.core.ProcessSystemDeclareKeys;
import com.wilmar.process.enumerate.EnumProcessSystemTagFixedVariableNameSet;
import com.wilmar.process.enumerate.EnumTagLibResource;

/**
 * @author MaKuBEX Email:makubexnet@gmail.com
 * @version 1.0.0
 */
public class TaskInstanceCommentFormTag extends ProcessFormRequirementTag {

	/**
	 * @serialField
	 */
	private static final long serialVersionUID = 1868890118102074060L;

	private String namespace;
	private String action;
	private String inputClass;
	private String inputStyle;
	private String buttonClass;
	private String buttonStyle;
	private String buttonValue;

	private String cols;
	private String rows;

	/**
	 * @see org.springframework.web.servlet.tags.RequestContextAwareTag#doStartTagInternal()
	 */
	protected int doStartTagInternal() throws Exception {
		StringBuffer html = new StringBuffer();
		String action_ = this.action;
		if (action_ == null || action.trim().length() == 0) {
			action_ = super.getContextPath() + this.namespace
					+ ProcessSystemDeclareKeys.SLASH
					+ "taskInstanceAction!doAddComment.action";
		}
		html.append("<form action=\"");
		html.append(action_);
		html.append("\" method=\"post\">");
		super.generateProcessInformationHtmlCode(html);
		html
				.append("<input type=\"hidden\" name=\""
						+ EnumProcessSystemTagFixedVariableNameSet.TASK_INSTANCE_COMMENTFORM_TASKINSTANCEID
						+ "\" id=\""
						+ EnumProcessSystemTagFixedVariableNameSet.TASK_INSTANCE_COMMENTFORM_TASKINSTANCEID
						+ "\" value=\""
						+ super
								.getAttribute(EnumProcessSystemTagFixedVariableNameSet.PROCESS_INFORMATION_TASK_INSTANCE_ID)
						+ "\"/>");
		html
				.append("<textarea name=\""
						+ EnumProcessSystemTagFixedVariableNameSet.TASK_INSTANCE_COMMENTFORM_COMMENT
						+ "\" id=\""
						+ EnumProcessSystemTagFixedVariableNameSet.TASK_INSTANCE_COMMENTFORM_COMMENT
						+ "\"");
		if (this.inputClass != null && this.inputClass.trim().length() != 0) {
			html.append(" class=\"");
			html.append(this.inputClass);
			html.append("\"");
		}
		if (this.inputStyle != null && this.inputStyle.trim().length() != 0) {
			html.append(" style=\"");
			html.append(this.inputStyle);
			html.append("\"");
		}
		if (this.rows != null && this.rows.trim().length() != 0) {
			html.append(" rows=\"");
			html.append(this.rows);
			html.append("\"");
		}
		if (this.cols != null && this.cols.trim().length() != 0) {
			html.append(" cols=\"");
			html.append(this.cols);
			html.append("\"");
		}
		html.append(">");
		html.append("</textarea>\n");
		html.append("<input type=\"submit\" value=\"");
		if (this.buttonValue != null && this.buttonValue.trim().length() != 0) {
			html.append(this.buttonValue);
		} else {
			html
					.append(super
							.getText(EnumTagLibResource.TASKINSTANCE_COMMENTFORM_SUBMIT_BUTTON));
		}
		html.append("\"");
		if (this.buttonClass != null && this.buttonClass.trim().length() != 0) {
			html.append(" class=\"");
			html.append(this.buttonClass);
			html.append("\"");
		}
		if (this.buttonStyle != null && this.buttonStyle.trim().length() != 0) {
			html.append(" style=\"");
			html.append(this.buttonStyle);
			html.append("\"");
		}
		html.append("/>");
		html.append("</form>");
		JspWriter outer = super.getOut();
		outer.write(html.toString());
		return SKIP_BODY;
	}

	/**
	 * @return the action
	 */
	public String getAction() {
		return action;
	}

	/**
	 * @param action
	 *            the action to set
	 */
	public void setAction(String action) {
		this.action = action;
	}

	/**
	 * @return the inputClass
	 */
	public String getInputClass() {
		return inputClass;
	}

	/**
	 * @param inputClass
	 *            the inputClass to set
	 */
	public void setInputClass(String inputClass) {
		this.inputClass = inputClass;
	}

	/**
	 * @return the inputStyle
	 */
	public String getInputStyle() {
		return inputStyle;
	}

	/**
	 * @param inputStyle
	 *            the inputStyle to set
	 */
	public void setInputStyle(String inputStyle) {
		this.inputStyle = inputStyle;
	}

	/**
	 * @return the buttonClass
	 */
	public String getButtonClass() {
		return buttonClass;
	}

	/**
	 * @param buttonClass
	 *            the buttonClass to set
	 */
	public void setButtonClass(String buttonClass) {
		this.buttonClass = buttonClass;
	}

	/**
	 * @return the buttonStyle
	 */
	public String getButtonStyle() {
		return buttonStyle;
	}

	/**
	 * @param buttonStyle
	 *            the buttonStyle to set
	 */
	public void setButtonStyle(String buttonStyle) {
		this.buttonStyle = buttonStyle;
	}

	/**
	 * @return the buttonValue
	 */
	public String getButtonValue() {
		return buttonValue;
	}

	/**
	 * @param buttonValue
	 *            the buttonValue to set
	 */
	public void setButtonValue(String buttonValue) {
		this.buttonValue = buttonValue;
	}

	/**
	 * @return the namespace
	 */
	public String getNamespace() {
		return namespace;
	}

	/**
	 * @param namespace
	 *            the namespace to set
	 */
	public void setNamespace(String namespace) {
		this.namespace = namespace;
	}

	/**
	 * @return the cols
	 */
	public String getCols() {
		return cols;
	}

	/**
	 * @param cols
	 *            the cols to set
	 */
	public void setCols(String cols) {
		this.cols = cols;
	}

	/**
	 * @return the rows
	 */
	public String getRows() {
		return rows;
	}

	/**
	 * @param rows
	 *            the rows to set
	 */
	public void setRows(String rows) {
		this.rows = rows;
	}
}
